package com.jason.controller;

import com.jason.model.entity.Video;
import com.jason.model.entity.VideoBanner;
import com.jason.service.VideoService;
import com.jason.utlis.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/v1/pub/video")
public class VideoController {
        @Autowired
        private VideoService videoService;

        /**
         * 视频列表
         * @return
         */
        @RequestMapping("/list")
        public JsonData listVideo(){
                List<Video> list=videoService.videoList();
            return JsonData.buildSuccess(list);
        }
        /**
         * 轮播图列表
         * @return
         */
        @GetMapping("/list_banner")
        public JsonData indexBanner(){
                List<VideoBanner> list=videoService.listBanner();
                return JsonData.buildSuccess(list);
        }

        /**
         * 查询视频详情，包含章 集信息
         * @param videoId
         * @return
         */
        @GetMapping("/find_detail_by_id")
        public JsonData findDetailById(@RequestParam(value = "video_id",required = true)int videoId){
                Video video=videoService.findDetailById(videoId);
                return JsonData.buildSuccess(video);

        }
}
